/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package quanlinganhang.model;

import java.sql.SQLException;
import java.util.ArrayList;
import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel;
import quanlinganhang.bus.AccountBUS;

/**
 *
 * @author phamduong
 */
public class AccountTypeComboModel extends AbstractListModel implements ComboBoxModel {
    
    private Object selectedItem;
    private ArrayList arrayList;
    
    public AccountTypeComboModel() throws SQLException, ClassNotFoundException {
        this.arrayList = new ArrayList<>();
        ArrayList temp = new ArrayList(AccountBUS.GetAccountTypes());
        int leng = temp.size();
        for (int i = 0; i < leng; i++) {
            this.arrayList.add(((ArrayList) temp.get(i)).get(1));
        }
    }
    
    @Override
    public int getSize() {
        return this.arrayList.size();
    }
    
    @Override
    public Object getElementAt(int index) {
        return this.arrayList.get(index);
    }
    
    @Override
    public void setSelectedItem(Object anItem) {
        this.selectedItem = anItem;
    }
    
    @Override
    public Object getSelectedItem() {
        return this.selectedItem;
    }
}
